<style>
    .form-horizontal .form-group{margin-right: -50px;}
    .col-sm-9{padding-right: 0;}
	.tm .btn { margin-bottom:5px;}
</style>
<div class="page-content">
    <div class="row form-horizontal form-validate">
        <div class="col-sm-8">
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 left-label" >模板名称</label>
			<div class="col-sm-9 col-xs-12">
				<input type="text"  id="title" name="title" ng-model="pagedata.item.title"  class="form-control" value="{{pagedata.item.title}}" placeholder="模版名称，例：订单完成模板1（自定义）" data-rule-required='true' />
			</div>
		</div>
		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 left-label">消息接口分组</label>
			<div class="col-sm-9 col-xs-12">
				<select class='form-control' ng-model="pagedata.item.typegroup"  id="typegroup" name="typegroup">
				   
						<option ng-repeat="type in pagedata.typegroup" value="{{type}}" >{{type}}</option>
				  
				</select>
			</div>
		</div>

		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 left-label">模板对应消息接口</label>
			<div class="col-sm-9 col-xs-12">
				<select class='form-control'  ng-model="pagedata.item.typecode"  id="typecode" name="typecode">
					 <option ng-repeat="code in pagedata.typecode" value="{{code}}" >{{code}}</option>
				</select>
			</div>
		</div>

		<div class="form-group">
			<label class="col-xs-12 col-sm-3 col-md-2 left-label">推送模式</label>
			<div class="col-sm-9 col-xs-12">
				<select class='form-control' ng-model="pagedata.item.massagetype"  id="massagetype" name="massagetype">
						<option  value="1" >发送模板消息</option>
						<option  value="2" >发送客服消息</option>
						<option  value="3" >发送混合消息</option>
				</select>
			   <!-- <span class='help-block'>混合消息发送方式为先发送模板消息,如果发送失败再次发送客服消息</span>-->
			</div>
		</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">设置客服消息内容</label>
					<div class="col-sm-9 col-xs-12">
						<textarea id="send_desc" name="send_desc" ng-model="pagedata.item.send_desc" style="height: 150px;resize: none;" class="form-control" placeholder='支持<a href=""></a>标签' >{{pagedata.item.send_desc}}</textarea>
						<div class="edit" style="width: 100%;height: 30px;border-bottom:1px solid #e5e6e7;border-left:1px solid #e5e6e7;border-right:1px solid #e5e6e7;">
							<div style="width: 30px;height: 30px;float: left;margin-left: 20px">
								<a href="javascript:" id="link" title="插入链接">
									<img src="../addons/jy_weishop/images/link.png" width="18px" height="18px" style="margin-top: 7px;">
								</a>
							</div>
						</div>
					</div>
				</div>
				<input type="hidden" name="tp_id" value="{$list['id']}" />
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label" >模板消息ID</label>
					<div class="col-sm-9 ">
						<input type="text" ng-model="pagedata.item.template_id"  id="tp_template_id" name="tp_template_id" class="form-control" ng-model="pagedata.item.template_id" placeholder="模版消息ID，例：P8MxRKmW7wdejmZl14-swiGmsJVrFJiWYM7zKSPXq4I" data-rule-required='true' /> 
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label" >头部标题</label>
					<div class="col-sm-8 title" style='padding-right:0' >
						<textarea name="tp_first" id="first" class="form-control" ng-model="pagedata.item.first" data-rule-required='true' placeholder="{{first.DATA}}" rows="5"></textarea>
						<span class='help-block'>对填充模板 first.DATA 的值 </span>
					</div>
					<div class="col-sm-1" style='padding-left:0;' >
						<input type="color" name="firstcolor" ng-model="pagedata.item.firstcolor" style="width:32px;height:32px;" />
					</div>
				</div>
				<div class="form-group" >
					<label class="col-xs-12 col-sm-3 col-md-2 left-label"></label>
					
				</div>
			   <div class="form-group" ng-show="pagedata.item.contents2[0]">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label" >{{pagedata.item.contents2[0]}}</label>
					<div class="col-sm-8 title" style='padding-right:0' >

						<textarea name="tp_first" id="keyword1" class="form-control" ng-model="pagedata.item.keyword1" data-rule-required='true' placeholder="{{first.DATA}}" rows="5"></textarea>
						<span class='help-block'>对填充模板{{pagedata.item.contents[1]}}的值 </span>
					</div>
				</div>
				 <div class="form-group" ng-show="pagedata.item.contents2[1]">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label" >{{pagedata.item.contents2[1]}}</label>

					
					<div class="col-sm-8 title" style='padding-right:0' >

						<textarea name="tp_first" id="keyword2" class="form-control" ng-model="pagedata.item.keyword2" data-rule-required='true' placeholder="{{first.DATA}}" rows="5"></textarea>
						<span class='help-block'>对填充模板{{pagedata.item.contents[2]}}的值 </span>
					</div>
				</div>
				 <div class="form-group" ng-show="pagedata.item.contents2[2]">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label" >{{pagedata.item.contents2[2]}}</label>
					<div class="col-sm-8 title" style='padding-right:0' >
						<textarea name="tp_first" id="keyword3" class="form-control" ng-model="pagedata.item.keyword3" data-rule-required='true' placeholder="{{first.DATA}}" rows="5"></textarea>
						<span class='help-block'>对填充模板{{pagedata.item.contents[3]}}的值 </span>
					</div>
				</div>
				<div class="form-group" ng-show="pagedata.item.contents2[3]">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label" >{{pagedata.item.contents2[3]}}</label>
					<div class="col-sm-8 title" style='padding-right:0' >

						<textarea name="tp_first" id="keyword4" class="form-control" ng-model="pagedata.item.keyword4" data-rule-required='true' placeholder="{{first.DATA}}" rows="5"></textarea>
						<span class='help-block'>对填充模板{{pagedata.item.contents[4]}}的值 </span>
					</div>
				</div>
				<div class="form-group" ng-show="pagedata.item.contents2[4]">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label" >{{pagedata.item.contents2[4]}}</label>
					<div class="col-sm-8 title" style='padding-right:0' >
						<textarea name="tp_first" id="keyword5" class="form-control" ng-model="pagedata.item.keyword5" data-rule-required='true' placeholder="{{first.DATA}}" rows="5"></textarea>
						<span class='help-block'>对填充模板{{pagedata.item.contents[5]}}的值 </span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label" >尾部描述</label>
					<div class="col-sm-8 title" style='padding-right:0' >
						<textarea name="tp_remark" id="remark" ng-model= "pagedata.item.remark" class="form-control" placeholder="{{remark.DATA}}" rows="5" ></textarea>
						<span class='help-block'>填充模板 remark.DATA 的值</span>
					</div>
					<div class="col-sm-1" style='padding-left:0' >
						<input type="color" name="remarkcolor" ng-model= "pagedata.item.remarkcolor" style="width:32px;height:32px;" />
					</div>
				</div>
			</div>
	<div class="col-sm-4" style="max-width:350px;">
        <div class="" >
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <span style="font-size: 15px"></span>请先选择模板
                </div>
                <div class="panel-body">
                    <select id="selecttemplate"  class=" form-control" style="margin-bottom: 5px;" ng-change="add()" ng-model="pagedata.item.tid">
                     <option ng-repeat="item in pagedata.tpl"  value="{{item.id}}">{{item.title}}</option>
					</select>
                    
                </div>
            </div>
        </div>

        
		<div class="  shilidiv"  >
            <div class="panel panel-default">
                <div class="panel-heading">
                    模板展示:
                </div>
                <div class="panel-body">
                    <div id="shili" class="text">
					{{pagedata.item.m}}
                    </div>
                </div>
            </div>
        </div>
		<div class="  shilidiv"  >
            <div class="panel panel-default">
                <div class="panel-heading">
                    模板示例:
                </div>
                <div class="panel-body">
                    <div id="shili" class="text">
					{{pagedata.item.example}}
                    </div>
                </div>
            </div>
        </div>
        <div class="">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <select class="form-control" onclick="$('.tm').hide();$('.tm-' + $(this).val()).show()">
                        <option value="">选择模板变量类型</option>
                        <option value="order">订单类</option>
                        <option value="upgrade">升级类</option>
                        <option value="rw">充值提现类</option>
                        
                        <option value="commission">分销类</option>
                       
                        <option value="globonus">股东类</option>
                       
                        <option value="merch">多商户类</option>
                       
                        <option value="pstore">门店类</option>
                        
                        <option value="bargain">砍价类</option>
                      
                        <option value="exchange">兑换中心</option>
                      
                        <option value="cashier">收银台类</option>
                        
                        <option value="lottery">游戏中心类</option>
                        
                    </select>
                </div>
                <div class="panel-body tm tm-upgrade" style="display:none">
                    <a href='JavaScript:' class="btn btn-default  btn-sm ">商城名称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">粉丝昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧等级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新等级</a>
                </div>
                <div class="panel-heading tm tm-rw" style="display:none">充值</div>

                <div class="panel-body tm tm-rw" style="display:none">
                    <a href='JavaScript:' class="btn btn-default  btn-sm">支付方式</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">充值金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">充值时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">赠送金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">实际到账</a>
                </div>

                <div class="panel-heading tm tm-rw" style="display:none">充值退款</div>
                <div class="panel-body tm tm-rw" style="display:none">
                    <a href='JavaScript:' class="btn btn-default  btn-sm">支付方式</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">充值金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">充值时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">赠送金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">实际到账</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">退款金额</a>
                </div>

                <div class="panel-heading tm tm-rw" style="display:none">提现</div>
                <div class="panel-body tm tm-rw" style="display:none">
                    <a href='JavaScript:' class="btn btn-default  btn-sm">提现金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">提现时间</a>
                </div>
                <div class="panel-heading tm tm-order" style="display:none">
                    订单信息
                </div>
                <div class="panel-body tm tm-order" style="display:none">
                    <a href='JavaScript:' class="btn btn-default  btn-sm">商城名称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">粉丝昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单号</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">运费</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">商品详情</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">单品详情</a>(单品商家下单通知变量)
                    <a href='JavaScript:' class="btn btn-default btn-sm">快递公司</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">快递单号</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">购买者姓名</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">购买者电话</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">收货地址</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">下单时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">支付时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">发货时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">收货时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">门店</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">门店地址</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">门店联系人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">门店营业时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">虚拟物品自动发货内容</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">虚拟卡密自动发货内容</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">自提码</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">备注信息</a>

                </div>
                <div class="panel-heading tm tm-order" style="display:none">
                    售后相关
                </div>
                <div class="panel-body tm tm-order" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">售后类型</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">退款金额</a>

                    <a href='JavaScript:' class="btn btn-default btn-sm">退货地址</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">换货快递公司</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">换货快递单号</a>

                </div>
                <div class="panel-heading tm tm-order" style="display:none">
                    订单状态更新
                </div>
                <div class="panel-body tm tm-order" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">粉丝昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单编号</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">原收货地址</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新收货地址</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单原价格</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单新价格</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">修改时间</a>
                </div>
                <div class="panel-heading tm tm-commission" style="display:none">成为下级或分销商</div>
                <div class="panel-body tm tm-commission" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                </div>
                <div class="panel-heading tm tm-commission" style="display:none">新增下线通知</div>
                <div class="panel-body tm tm-commission" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">下线层级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">下级昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                </div>
                <div class="panel-heading tm tm-commission" style="display:none">下级付款类</div>
                <div class="panel-body tm tm-commission" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">下级昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单编号</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">订单金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">商品详情</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">佣金金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">下线层级</a>
                </div>
                <div class="panel-heading tm tm-commission" style="display:none">提现申请和佣金打款类</div>
                <div class="panel-body tm tm-commission" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">提现方式</a>
                </div>
                <div class="panel-heading tm tm-commission" style="display:none">分销商等级升级通知</div>
                <div class="panel-body tm tm-commission" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧等级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧一级分销比例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧二级分销比例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧三级分销比例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新等级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新一级分销比例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新二级分销比例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新三级分销比例</a>
                </div>



                <div class="panel-heading tm tm-globonus" style="display:none">成为股东</div>
                <div class="panel-body tm tm-globonus" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                </div>

                <div class="panel-heading tm tm-globonus" style="display:none">股东等级升级通知</div>
                <div class="panel-body tm tm-globonus" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧等级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">旧分红例</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新等级</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">新分红比例</a>
                </div>
                <div class="panel-heading tm tm-globonus" style="display:none">分红发放通知</div>
                <div class="panel-body tm tm-globonus" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">打款方式</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">金额</a>
                </div>

                <div class="panel-heading tm tm-merch" style="display:none">入驻申请</div>
                <div class="panel-body tm tm-merch" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">商户名称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">主营项目</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">手机号</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请时间</a>
                </div>
                <div class="panel-heading tm tm-merch" style="display:none">入驻申请(用户)</div>
                <div class="panel-body tm tm-merch" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">驳回原因</a>
                </div>

                <div class="panel-heading tm tm-bargain" style="display:none">砍价类</div>
                <div class="panel-body tm tm-bargain" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">砍价金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">当前金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">砍价时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">砍价人昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">砍掉或增加</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">成功或失败</a>
                </div>
                <div class="panel-heading tm tm-exchange" style="display:none">兑换中心</div>
                <div class="panel-body tm tm-exchange" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">兑换时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">兑换面值</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">粉丝昵称</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">商城名称</a>
                </div>
                <div class="panel-heading tm tm-pstore" style="display:none">申请通知</div>
                <div class="panel-body tm tm-pstore" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系电话</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请时间</a>
                </div>

                <div class="panel-heading tm tm-pstore" style="display:none">申请结算通知</div>
                <div class="panel-body tm tm-pstore" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系电话</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请金额</a>
                </div>

                <div class="panel-heading tm tm-pstore" style="display:none">审核通知</div>
                <div class="panel-body tm tm-pstore" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系电话</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">审核状态</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">审核时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">驳回原因</a>
                </div>

                <div class="panel-heading tm tm-pstore" style="display:none">打款通知</div>
                <div class="panel-body tm tm-pstore" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系电话</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">打款时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">打款金额</a>

                </div>

                <div class="panel-heading tm tm-pstore" style="display:none">门店支付通知</div>
                <div class="panel-body tm tm-pstore" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">付款人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">付款金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">付款时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">门店名称</a>

                </div>

                <!--收银台模板消息 begin-->
                <div class="panel-heading tm tm-cashier" style="display:none">申请结算通知</div>
                <div class="panel-body tm tm-cashier" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系电话</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请金额</a>
                </div>

                <div class="panel-heading tm tm-cashier" style="display:none">打款通知</div>
                <div class="panel-body tm tm-cashier" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系人</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">联系电话</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">打款时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">申请金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">打款金额</a>
                </div>

                <div class="panel-heading tm tm-cashier" style="display:none">支付通知</div>
                <div class="panel-body tm tm-cashier" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">付款金额</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">余额抵扣</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">付款时间</a>
                    <a href='JavaScript:' class="btn btn-default btn-sm">收银台名称</a>

                </div>

                <div class="panel-heading tm tm-lottery" style="display:none">获得抽奖通知</div>
                <div class="panel-body tm tm-lottery" style="display:none">
                    <a href='JavaScript:' class="btn btn-default btn-sm">活动名称</a>
                </div>

                <div class="panel-body">
                    点击变量后会自动插入选择的文本框的焦点位置，在发送给粉丝时系统会自动替换对应变量值
                    <div class="text text-danger">
                        注意：以上模板消息变量只适用于系统类通知，会员群发工具不适用
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<div class="modal-sub"><button class="btn btn-primary" href="javascript:" ng-click="post(pagedata.item,'post')">提交</button></div>
</div>
<script type="text/javascript">
scope.add = function(){
	scope.pagedata.item.example=scope.pagedata.tpl[scope.pagedata.item.tid].example;
	scope.pagedata.item.contents2=scope.pagedata.tpl[scope.pagedata.item.tid].contents2;
	scope.pagedata.item.contents=scope.pagedata.tpl[scope.pagedata.item.tid].contents;
	scope.pagedata.item.template_id=scope.pagedata.tpl[scope.pagedata.item.tid].template_id;
	scope.pagedata.item.m=scope.pagedata.tpl[scope.pagedata.item.tid].m;
	scope.$apply();
}

</script>
<script language='javascript'>

    var kw = 1;
    var temps;
    var contents;
    restempoption();

    function selecttemp()
    {
        var tid = $("#selecttemplate").val();
        var temp;

        for(var i=0;i<temps.length;i++){
            if(temps[i].template_id==tid)
            {
                temp =temps[i];
                break;
            }
        }

        if(temp==null)
        {
            return;
        }else
        {
            contents = temp.contents;

            if(contents[0]!='first'||contents[contents.length-1]!='remark')
            {
                alert("此模板不可用!");
                return;
            }
            $("#shili").html(temp.content);

            $(".shilidiv").show();

            $("#tp_title").val(temp.title);
            $("#tp_template_id").val(temp.template_id);

            $('.key_item').remove();

            setcontents(0);
        }
    }


    function setcontents(i){

        if(contents.length==i)
        {
            return;
        }
        if(contents[i]!='first'&&contents[i]!='remark')
        {
            var data = {
                tpkw: contents[i]
            };
            $.ajax({
                url: "{php echo webUrl('sysset/tmessage/tpl')}",
                cache: false,
                data:data
            }).done(function (html) {
                $(".btn-add-type").button("reset");
                $("#type-items").append(html);
                i++
                setcontents(i);
            });
        }else
        {
            i++
            setcontents(i);
        }
    }



    function addtempoption() {
        var tempcode = $("#tempcode").val();
        var data = {
            templateidshort: tempcode
        };
        $.ajax({
            url: "{php echo webUrl('sysset/tmessage/gettemplateid')}",
            data: data,
            cache: false
        }).done(function (result) {

            var  data= jQuery.parseJSON(result);

            if(data.status==1) {
                alert("加入成功");
                restempoption();
            }else
            {
                alert("失败");
                alert(data.result.message);
            }

        });
    }


    function deltempoption() {
        var tid = $("#selecttemplate").val();
        var data = {
            template_id: tid
        };
        $.ajax({
            url: "{php echo webUrl('sysset/tmessage/deltemplatebyid')}",
            data: data,
            cache: false
        }).done(function (result) {

            var  data= jQuery.parseJSON(result);

            if(data.status==1) {
                alert("删除成功");
                restempoption();
            }else
            {
                alert("失败");
                alert(data.result.message);
            }

        });
    }

    function restempoption() {
        $.ajax({
            url: "{php echo webUrl('sysset/tmessage/gettemplatelist')}",
            cache: false
        }).done(function (result) {

            var  data= jQuery.parseJSON(result);

            if(data.status==1)
            {
                $("#selecttemplate option").remove();

                temps =data.result.template_list;
                for(var i=0;i<temps.length;i++){

                    $("#selecttemplate").append("<option value='"+temps[i].template_id+"'>"+temps[i].title+"</option>");
                }
            }
        });
    }

    function addType() {
        $(".btn-add-type").button("loading");
        $.ajax({
            url: "{php echo webUrl('sysset/tmessage/tpl')}&kw="+kw,
            cache: false
        }).done(function (html) {
            $(".btn-add-type").button("reset");
            $("#type-items").append(html);
        });
        kw++;
    }

 $(function () {
        require(['jquery.caret'],function(){
            var jiaodian;
            $(document).on('focus', 'input,textarea',function () {
                jiaodian = this;
            });

            $("a[href='JavaScript:']").click(function () {
                if (jiaodian) {
                    $(jiaodian).insertAtCaret("["+this.innerText+"]" );
					
					scope.pagedata.item.first=$("#first").val();
					scope.pagedata.item.remark=$("#remark").val();
					scope.pagedata.item.keyword1=$("#keyword1").val();
					scope.pagedata.item.keyword2=$("#keyword2").val();
					scope.pagedata.item.keyword3=$("#keyword3").val();
					scope.pagedata.item.keyword4=$("#keyword4").val();
					scope.pagedata.item.keyword5=$("#keyword5").val();
					scope.$apply();
					
                }
            })

        })
    })

</script>
<script>
    require(['jquery','util'], function($, util){
        $(function(){
            $('#btn').click(function(){
                util.emojiBrowser(function(emoji){
                    var text = '[U+'+emoji[0].text+']';
                    var content = $('#send_desc').val()+text;
                    $('#send_desc').val(content);

                });
            });
        });

        $(function(){
            util.emotion($('#emotion'), $('#send_desc'));
        });

        $(function () {
            $('#link').click(function () {
                var link='<a href=\\"您要插入的链接\\">链接文字</a>';
                var content = $('#send_desc').val()+link;
                $('#send_desc').val(content);
            });
        });
    });
</script>
